package com.lx.dynamicdatasouce.mybatis.demo.aspect;

import com.lx.dynamicdatasouce.mybatis.demo.annotation.WR;
import com.lx.dynamicdatasouce.mybatis.demo.config.DynamicDataSource;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

/**
 * @author lX
 * @version JDK 8
 * @className DynamicDataSourceAspect (此处以class为例)
 * @date 2024/10/7
 * @description TODO
 */
@Component
@Aspect
public class DynamicDataSourceAspect  implements Ordered {





    // 前置
    @Before("within(com.lx.dynamicdatasouce.demo.service.impl.*) && @annotation(wr)")
    public void before(JoinPoint point, WR wr){
        String name = wr.value();
        DynamicDataSource.name.set(name);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
